function rie = computeRie(i,elements,model)
e = model.getElement(i-1);
f = e.getFace();
xi = e.getGaussPoint(0);
w = e.getGaussWeight(0);
jac = f.jacXAt(xi);
detJac = det(jac);
B = zeros(3,6);
B = e.computeB(f,B,[xi(1) xi(2)]);
if elements(i).isCrack==1
    sigma = elements(i).stress;
    renh = elements(i).renh;
    %compute rie
    rie = w*B'*sigma*abs(detJac)+...
        elements(i).Kdxi*(elements(i).Kxixi\renh);
%     renh'
%     sigma'
%     rie'
else
    sigma = elements(i).stress;
    rie = w*B'*sigma*abs(detJac);
end
end
